import { init } from 'snabbdom/build/package/init'
import { h } from 'snabbdom/build/package/h'

/* 1. 导入模块 */
import { styleModule } from 'snabbdom/build/package/modules/style' // 设置行内样式
import { eventListenersModule } from 'snabbdom/build/package/modules/eventlisteners' // 注册事件

/* 2. 注册模块 */
let patch = init([
  styleModule,
  eventListenersModule
])

const vnode = h('div', {
  style: {
    backgroundColor: 'pink'
  },
  on: {
    click: handleClick
  }
}, [
  h('h1', 'Hello h1'),
  h('p', 'this is p')
])

function handleClick() {
  console.log('触发了点击事件')
}

const app = document.querySelector('#app')

let oldVNode = patch(app, vnode)
